package com.syb.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.syb.dao.RoleDao;
import com.syb.entity.function.SysRole;
import com.syb.service.RoleService;
import com.syb.util.PageResults;

@Service
public class RoleServiceImpl implements RoleService{
	
	@Autowired
	private RoleDao roleDao;

	public PageResults<SysRole> findSysRoleList(PageResults<SysRole> page) throws Exception {
		PageResults<SysRole> sysRolePageList = new PageResults<SysRole>();
		List<SysRole> sysRoleList = new ArrayList<SysRole>();
		int count = 0;
		try{
			sysRoleList = roleDao.findSysRoleList(page);
		}catch(Exception e){
			throw new Exception(e.getMessage());
		}
		try{
			count = roleDao.findSysRoleCount(page);
		}catch(Exception e){
			throw new Exception(e.getMessage());
		}
		sysRolePageList.setPageNo((page.getCurrentPage()/page.getPageSize())+1);
		sysRolePageList.setResults(sysRoleList);
		sysRolePageList.setTotalCount(count);
		return sysRolePageList;
	}

}
